package com.example.thegreatwall.common;


import com.example.thegreatwall.controller.UsersController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

//文件上传
@RestController
public class FileUpload {
    //注入oss工具类
    @Autowired
    private AliOSSUtil aliOSSUtil;
    @Autowired
    private UsersController usersController;

    @PostMapping("/upload")
    @ResponseBody
    public R upload(@RequestParam("file") MultipartFile file) throws IOException {
        //调用上传文件传到阿里云的方法
        String url = aliOSSUtil.upload(file);

        return new R().addDate("url",url);
    }
}
